﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DO.DreamOnTrader.Quote;
using DO.DreamOnTrader;
using System.Threading;

namespace testQuote
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();

			
		}
		TickFileTickBuilder hs = new TickFileTickBuilder(@"C:\Documents and Settings\Administrator\桌面\新資料夾\temptick\", ProductSet.TX, 0, 20);
		RecoverTickBuilder roq = new RecoverTickBuilder(ProductSet.TX);
		RealTimeTickBulder rq = new RealTimeTickBulder(ProductSet.TX);
		KBarFileKBarBuilder kbb = new KBarFileKBarBuilder(@"C:\Documents and Settings\Administrator\桌面\新資料夾\temptick\");

		private void Form1_Load(object sender, EventArgs e)
		{

			hs.BuildingNewTick += new BuildingNewTickEventHandler(printNewQuote);
			hs.BuildingTick += new BuildingTickEventHandler(this.printGetQuote);
			hs.EndQuote += new EndQuoteEventHandler(this.printEndQuote);

			roq.BuildingNewTick += new BuildingNewTickEventHandler(this.printNewQuote);
			roq.BuildingTick += new BuildingTickEventHandler(this.printGetQuote);
			roq.EndQuote += new EndQuoteEventHandler(this.printEndQuote);


			rq.BuildingNewTick += new BuildingNewTickEventHandler(this.printNewQuote);
			rq.BuildingTick += new BuildingTickEventHandler(this.printGetQuote);
			rq.EndQuote += new EndQuoteEventHandler(this.printEndQuote);


			kbb.fileFolder = @"C:\Documents and Settings\Administrator\桌面\新資料夾\temptick\";
			kbb.BuildingKBar += new BuildingKBarEventHandler(this.printGetQuote);
			kbb.BuildingKBar += new BuildingKBarEventHandler(this.printGetQuote);
			kbb.BuildingKBar += new BuildingKBarEventHandler(this.printGetQuote);
			kbb.BuildingKBar += new BuildingKBarEventHandler(this.printGetQuote);
			kbb.EndQuote += new EndQuoteEventHandler(this.printEndQuote);
		}

		private void printGetQuote(KBar kbar)
		{
			DO.Common.Trace.InfoWrite("getQuote", kbar.ToString());
		}

		private void printNewQuote(KBar kbar)
		{
			DO.Common.Trace.InfoWrite("newQuote", kbar.ToString());
		}

		private void printGetQuote(Tick tick)
		{
			DO.Common.Trace.InfoWrite("getQuote", tick.ToString());
		}

		private void printNewQuote(Tick tick)
		{
			DO.Common.Trace.InfoWrite("newQuote", tick.ToString());
		}

		private void printEndQuote(object sender, EventArgs e)
		{
			DO.Common.Trace.InfoWrite("EndQuote", "結束報價");
		}

		private void button1_Click(object sender, EventArgs e)
		{
			DO.Common.Trace.SetLogFile("", "HistoryQuote");
			hs.Start();
		}

		private void button3_Click(object sender, EventArgs e)
		{
			DO.Common.Trace.SetLogFile("", "RealTimeQuote");
			rq.Start();
		}

		private void button2_Click(object sender, EventArgs e)
		{
			DO.Common.Trace.SetLogFile("", "no null");
			roq.Start();
		}

		private void button4_Click(object sender, EventArgs e)
		{
			DO.Common.Trace.SetLogFile("", "KBarFile");
			kbb.Start();
		}

		private void button5_Click(object sender, EventArgs e)
		{
			textBox1.Text += "1";
		}
	}
}
